﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:wvrm="http://ns.woodbase.dk/Menu.xsd"
>
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">
    <div class="leftMenu">
      <ul class="MLvl-1">
        <xsl:choose>
          <xsl:when test="fullsite">
            <xsl:apply-templates select="fullsite/wvrm:menuitem">
              <xsl:with-param name="depth" select="1" />
            </xsl:apply-templates>    
          </xsl:when>
          <xsl:otherwise>
            <xsl:apply-templates select="/wvrm:menuitem">
              <xsl:with-param name="depth" select="1" />
            </xsl:apply-templates>
          </xsl:otherwise>
        </xsl:choose>
      </ul>
    </div>
  </xsl:template>

  <xsl:template match="//wvrm:menuitem">
    <xsl:param name="depth" />
    <li>
      <a href="{@url}">
        <xsl:value-of select="@title"/>
      </a>
      <xsl:if test="count(wvrm:menuitem)">
        <ul class="MLvl-{$depth+1}">
          <xsl:apply-templates select="wvrm:menuitem">
            <xsl:with-param name="depth" select="$depth+1" />
          </xsl:apply-templates>
        </ul>
      </xsl:if>
    </li>
  </xsl:template>
</xsl:stylesheet>